<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Promise状态修改一次</title>
    <script src="Promise.js"></script>
</head>
<body>
<script>
    /*
    pending -> resolved
    pending -> rejected
       改变状态只有这2种, 且一个promise对象只能改变一次
       无论变为成功还是失败, 都会有一个结果数据
       成功的结果数据一般称为value, 失败的结果数据一般称为reason
     */
    let p = new Promise((resolve, reject) => {
        resolve('OK');
        reject('Error');
    });

    p.then(value => {
        console.log(value);
    }, reason => {
        console.error(reason);
    });
    
</script>
</body>
</html>